package com.jerkin.trace;

/**
 * @version V1.0
 * @ClassName: TestRandom
 * @Description:
 * @author: huhongzhi
 * @date: 2020/7/28 10:11
 */
public class TestRandom {

    public static void main(String[] args) {
        int value = getSerialAsc("3560ad4", 4);
        System.out.println(value);

    }

    public static int getSerialAsc(String serial, int nums) {
        int len = serial.length();
        String useSerial = serial.substring(len - nums, len);
        char[] chars = useSerial.toCharArray();
        int count = 0;
        for (int i = 0; i < chars.length; i++) {
            double value = Math.pow(10D, nums - 1D - i);
            count += chars[i] * value;
        }
        return count;
    }
}
